Skip to content

Check the code enhancement and remove if not useful#23664

Closed
Durgesh-Kumar-Dewangan wants to merge 9 commits intogoogle-gemini:mainfrom
Durgesh-Kumar-Dewangan:main
Closed

Check the code enhancement and remove if not useful#23664
Durgesh-Kumar-Dewangan wants to merge 9 commits intogoogle-gemini:mainfrom
Durgesh-Kumar-Dewangan:main

Conversation

@Durgesh-Kumar-Dewangan
Copy link
Copy Markdown

Summary

This PR prevents the use of tool restriction fields in evaluation configurations and adds compile-time safeguards to enforce this. It ensures evals run with the full default toolset for more realistic and consistent behavior.

Details
Disallowed tool restriction fields: excludeTools, allowedTools, coreTools, mainAgentTools
Introduced a TypeScript utility type (NoToolRestrictions) to enforce this at compile time
Added runtime sanitization in eval helpers to remove restricted fields if passed dynamically (e.g., via as any or external configs)
Updated eval files to align with the new constraints without modifying test logic or behavior

#Related Issues
Fixes #23312
Related to #23310
Related to #20328
Related to #20571
Related to #18617

@Durgesh-Kumar-Dewangan Durgesh-Kumar-Dewangan requested a review from a team as a code owner March 24, 2026 13:12
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request strengthens the integrity and predictability of evaluation configurations by strictly prohibiting the use of tool restriction fields. It achieves this through a dual approach of compile-time type enforcement and runtime sanitization, ensuring that all evaluations consistently utilize the full, default toolset. This change aims to prevent unintended deviations in evaluation behavior and promotes more realistic testing scenarios. Additionally, it enhances the robustness of argument parsing within several evaluation files.

Highlights

  • Enforced Tool Restriction Prevention: Introduced compile-time type safety using a new TypeScript utility type (NoToolRestrictions) to prevent the use of specific tool restriction fields (excludeTools, allowedTools, coreTools, mainAgentTools) in evaluation configurations.
  • Runtime Sanitization: Implemented a runtime sanitization function (sanitizeConfigOverrides) that dynamically removes any forbidden tool restriction fields from evaluation configurations, ensuring consistent behavior even if type safety is bypassed.
  • Improved Tool Argument Parsing: Added a parseToolArgs utility function in several evaluation files to safely parse tool arguments, replacing direct JSON.parse calls and improving robustness against malformed input.
  • Evaluation File Updates: Updated existing evaluation files (generalist_delegation.eval.ts, model_steering.eval.ts, save_memory.eval.ts) to explicitly use the new NoToolRestrictions type, enforcing the new constraints across the evaluation suite.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors evaluation configurations to enforce tool restriction policies and improves the robustness of tool argument parsing. It introduces ForbiddenToolKeys and NoToolRestrictions types to prevent specific tool restriction configurations in evaluation setups at compile-time. A new sanitizeConfigOverrides function was added to app-test-helper.ts to remove these forbidden keys at runtime, ensuring evals always use the full tool set. Additionally, a parseToolArgs helper function was introduced and applied across several evaluation files (grep_search_functionality.eval.ts, validation_fidelity.eval.ts, validation_fidelity_pre_existing_errors.eval.ts) to safely parse tool arguments, handling both object and string inputs, and improving error handling for malformed JSON. Minor formatting adjustments and a refined prompt for a delegation test were also included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant